﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Text.RegularExpressions;
using System.Web;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CookieContainer cc = new CookieContainer();
            String pspt = "http://211.140.25.246:7080/wlan/index.wlan?wlanacname=0021.0574.571.00&wlanuserip=10.226.250.229&ssid=CMCC&nasip=120.193.25.98&wlannasid=3024237457100460";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pspt);
            req.Method = "get";
            req.Accept = "text/html, application/xhtml+xml, */*";
            //req.Referer = "http://cloud.vip.xunlei.com/task.html";
            req.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
            //  req.Host = "jump.xunlei.com";
            req.KeepAlive = true;

            req.CookieContainer = cc;
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            cc.Add(resp.Cookies);
            String stroe = new StreamReader(resp.GetResponseStream()).ReadToEnd();
            String stroe2 = stroe.Substring(stroe.IndexOf("action=") + 8, stroe.IndexOf(">", stroe.IndexOf("action=")) - stroe.IndexOf("action=") - 9);
           // String stroe2 = (stroe.IndexOf("action=", stroe.IndexOf(">"))-stroe.IndexOf("action=")).ToString();
           // String stroe2 = stroe.IndexOf(">", stroe.IndexOf("action=")).ToString();
          //  String stroe2 = stroe.IndexOf("action=").ToString();
            richTextBox1.AppendText(stroe);

            System.Net.WebClient WebClientObj = new System.Net.WebClient();
            System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();
            PostVars.Add("wlanAcName", "0021.0574.571.00");
            PostVars.Add("wlanAcIp", "");
            PostVars.Add("wlanUserIp", "10.226.250.229");
            PostVars.Add("ssid", "CMCC");
            PostVars.Add("userName", "15957899036");
            PostVars.Add("userPwd", "7d549b");
            //  PostVars.Add("verifyHidden", "");
            PostVars.Add("verifyCode", "");
            byte[] byRemoteInfo = WebClientObj.UploadValues(stroe2, "POST", PostVars);

            string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo);

            richTextBox1.Text += sRemoteInfo;
          
        }
    }
}
